const mongoose = require('mongoose')
const Scheme = mongoose.Schema
mongoose.connect('mongodb://localhost/code_order')

const moment = require('moment')

const userSchema = new Scheme({
  openId: {  //openId
    type: String,
    required: true
  },
  nickName: {  //昵称
    type: String,
    required: true
  },
  avatarUrl: {  //头像
    type: String,
  },
  password: {  //密码
    type: Number,
    default: 123456
  },
  mobile: {  //手机
    type: Number
  },
  gender: {  //性别  0女 1男
    type: Number
  },
  birthday: {  //生日
    type: String
  },
  money: {  //余额
    type: Number,
    default: 0
  },
  name: {  //姓名
    type: String
  },
  createTime: {  //创建时间
    type: String,
    default: moment().format("YYYY-MM-DD HH:mm:ss")
  }
})

const user = mongoose.model('user', userSchema)
module.exports = user
